﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace EzDesk.EzAppApi.Utility.Models
{
    public class AppTaskCollection : List<AppTask>
    {
        public void AddTask(string title, string description, string funcUrl)
        {
            this.Add(new AppTask()
            {
                Title = title,
                Description = description,
                FuncUrl = funcUrl,
            });
        }

        public string ToXmlString()
        {
            XElement appTasks = new XElement("apptasks");
            foreach (var task in this)
            {
                XElement appTask = new XElement("apptask");
                appTask.Add(new XAttribute("title", task.Title));
                appTask.Add(new XAttribute("description", task.Description));
                appTask.Add(new XAttribute("funcurl", task.FuncUrl));

                appTasks.Add(appTask);
            }
            return appTasks.ToString();
        }
    }
}
